<!DOCTYPE html>
<html>
     <head>
         <meta charset="utf-8">
         <title > web 与 js 交互示例 </title>
          <script>          
             function callAndroid(){
                   test.hello();
              }

             function callAndroidWithParam(){
                   test.hello("Eric");
             }

              function callAndroid2(){
                  /*约定的url协议为：js://webview?arg1=111&arg2=222*/
                  document.location = "js://webview?arg1=111&arg2=222";
              }
              function clickprompt(){
                  // 调用prompt（）  js://demo 为android 与js 约定的协议 arg1 arg2为参数
                  var result= prompt("js://demo?arg1=111&arg2=222");
                  // alert("demo " + result);
              }
            
              function confirmTest(){
                  var result= confirm("js://confirm?gender=male&name=Eric");
                  
              }

              function resultBack(text){
                 alert("返回结果：" + text);                     
              }

         </script>


     </head>

     <body>
          <!-- //点击按钮则调用callAndroid函数 -->
          <button type="button" id="button1" onclick="callAndroid()">调用android无参hello函数</button>
          <button type="button" id="button2" onclick="callAndroidWithParam()">调用android有参hello函数</button>
          <button onclick="callAndroid2()">shouldOverrideUrlLoading测试</button>
          <button type="button" id="button3" onclick="clickprompt()">Prompt测试</button>
          <button type="button" id="button4" onclick="confirmTest()">confirm测试</button>


     </body>
</html>